<script setup>
import { ref } from 'vue'

const user = ref({})

const formSchema = [
  {
    type: 'input',
    label: '用户ID',
    model: 'userId',
    placeholder: '请输入用户ID'
  },
  {
    type: 'input',
    label: '用户名称',
    model: 'userName',
    placeholder: '请输入用户名称'
  },
  {
    type: 'select',
    label: '状态',
    model: 'state',
    placeholder: '请选择状态',
    options: [
      {
        label: '所有',
        value: 0,
        disabled: true
      },
      {
        label: '在职',
        value: 1
      },
      {
        label: '离职',
        value: 2
      },
      {
        label: '试用期',
        value: 3
      }
    ]
  }
]

const handleQuery = () => {
  console.log(user.value)
}

const columns = [
  {
    type: 'selection'
  },
  {
    label: '用户ID',
    prop: 'userId'
  },
  {
    label: '用户名',
    prop: 'userName'
  },
  {
    type: 'action',
    label: '操作',
    list: [
      {
        type: 'primary',
        text: '编辑'
      },
      {
        text: '删除'
      }
    ]
  }
]
const userList = [
  { userId: 1, userName: 'Jack' },
  { userId: 2, userName: 'Tom' }
]
</script>

<template>
  <QueryForm
    :formSchema="formSchema"
    v-model="user"
    @handle-query="handleQuery"
  />

  <BaseTable :columns="columns" :data="userList">
    <template v-slot:action>
      <el-button type="primary">查询</el-button>
    </template>
  </BaseTable>
</template>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
